<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>项目管理 - 健身俱乐部</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">

</head>
<body>
<h2>项目管理</h2>
<a href="adminHome.html" class="back-btn">返回管理员首页</a>
<!-- 添加新项目表单 -->
<div class="form-container">
    <h3>添加新项目</h3>
    <form action="ProjectServlet" method="post">
        <input type="hidden" name="action" value="add">
        <div class="form-group">
            <label for="projectName">项目名称:</label>
            <input type="text" id="projectName" name="projectName" required>
        </div>
        <div class="form-group">
            <label for="pricePerHour">每小时价格:</label>
            <input type="number" id="pricePerHour" name="pricePerHour" step="0.01" required>
        </div>
        <div class="form-group">
            <label for="description">项目描述:</label>
            <textarea id="description" name="description" rows="3"></textarea>
        </div>
        <button type="submit" class="add-btn">添加项目</button>
    </form>
</div>

<!-- 项目列表 -->
<h3>项目列表</h3>
<c:if test="${empty projectList}">
    <p>暂无项目记录</p>
</c:if>
<c:if test="${not empty projectList}">
    <table>
        <thead>
        <tr>
            <th>项目ID</th>
            <th>项目名称</th>
            <th>每小时价格</th>
            <th>项目描述</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${projectList}" var="project">
            <tr>
                <td>${project.projectId}</td>
                <td>${project.projectName}</td>
                <td>${project.pricePerHour} 元</td>
                <td>${project.description}</td>
                <td>
                    <a href="ProjectServlet?action=delete&projectId=${project.projectId}"
                       class="delete-btn"
                       onclick="return confirm('确定要删除该项目吗？')">删除</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>

    </table>
</c:if>
</body>
</html>